﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using IDAL;
using Model;

namespace DAL
{
    public class JointingFailure : BaseRepository<JointingFailureInfo>, IJointingFailure
    {
        #region 静态变量部分
        private const string PARM_JOINTINGFAILURE_FAILUREID = "@FailureID";
        private const string PARM_JOINTINGFAILURE_FAILURENAME = "@FailureName";
        private const string PARM_JOINTINGFAILURE_FAILURETYPE = "@FailureType";
        private const string PARM_JOINTINGFAILURE_REPAIRPATH = "@RepairPath";
        #endregion

        #region 数据检索部分
        public IList<JointingFailureInfo> LoadEntities()
        {
            return null;
        }

        /// <summary>
        /// Get an individual category based on a provided id
        /// </summary>
        /// <param name="categoryId">Category id</param>
        /// <returns>Details about the Category</returns>
        public JointingFailureInfo LoadEntity<T1>(T1 failureID)
        {
            return null;
        }

        public IList<JointingFailureInfo> JointingFailure_GetbyMan()
        {
            return ExcuteSqlToGetEntities("JointingFailure_selectbyMan");
        }

        public IList<JointingFailureInfo> JointingFailure_GetbySMT()
        {
            return ExcuteSqlToGetEntities("JointingFailure_selectbySMT");
        }

        public IList<JointingFailureInfo> JointingFailure_GetbyApp()
        {
            return ExcuteSqlToGetEntities("JointingFailure_selectbyApp");
        }

        public IList<JointingFailureInfo> JointingFailure_GetbyQCFix()
        {
            return ExcuteSqlToGetEntities("JointingFailure_selectbyQCFix");
        }

        public IList<JointingFailureInfo> JointingFailure_GetbyPack()
        {
            return ExcuteSqlToGetEntities("JointingFailure_selectbyPack");
        }

        public JointingFailureInfo JointingFailure_GetbyTypeAndName(string failureType, string failureName)
        {
            SqlParameter[] parms = GetTypeAndNameParameter();
            parms[0].Value = failureType;
            parms[1].Value = failureName;
            return ExcuteSqlToGetEntity("JointingFailure_selectbyTypeAndName", parms);
        }
        #endregion

        #region 参数部分
        private SqlParameter[] GetTypeAndNameParameter()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
                    new SqlParameter(PARM_JOINTINGFAILURE_FAILURETYPE,SqlDbType.NChar, 5),
					new SqlParameter(PARM_JOINTINGFAILURE_FAILURENAME, SqlDbType.NVarChar, 50)
                };
            return parms;
        }
        #endregion

        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override JointingFailureInfo GetEntityRecord(SqlDataReader rdr)
        {
            JointingFailureInfo pro = new JointingFailureInfo(rdr.GetInt32(0), rdr.GetValue(1).ToString(),rdr.GetValue(2).ToString());
            return pro;
        }

        public override JointingFailureInfo GetEntityRecord()
        {
            JointingFailureInfo pro = new JointingFailureInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "JointingFailure_Insert";
        }

        public override string GetUpdatesp()
        {
            return "JointingFailure_Update";
        }

        public override string GetDeletesp()
        {
            return "JointingFailure_delete";
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter parm = new SqlParameter(PARM_JOINTINGFAILURE_FAILUREID, SqlDbType.Int, 4);
            return parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_JOINTINGFAILURE_FAILUREID, SqlDbType.Int, 4),
					new SqlParameter(PARM_JOINTINGFAILURE_FAILURENAME, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_JOINTINGFAILURE_FAILURETYPE,SqlDbType.NChar, 5),
                    new SqlParameter(PARM_JOINTINGFAILURE_REPAIRPATH,SqlDbType.NVarChar, 50),
                };
            return parms;
        }

        public override void SetParameters(JointingFailureInfo jointingFailure, params SqlParameter[] Parms)
        {
            Parms[0].Value = jointingFailure.FailureID;
            Parms[1].Value = jointingFailure.FailureName;
            Parms[2].Value = jointingFailure.FailureType;
            Parms[3].Value = jointingFailure.RepairPath;
        }
        #endregion
    }
}
